﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Control_General_MessageBox : System.Web.UI.UserControl,IMessage
{
    private MessageType type;

    public MessageType Type
    {
        get { return type; }
        set { 
            
            type = value;
         
        
        }
    }
  

    private string cssMessage;

    public string CssMessage
    {
        get { return cssMessage; }
        set { cssMessage = value; }
    }

    

    public List<Message> MessageList
    {
        set {
            Repeater1.DataSource = value;
            Repeater1.DataBind();
        }
    }


    protected void Page_Load(object sender, EventArgs e)
    {


      
    }

    protected override void OnPreRender(EventArgs e)
    {
        CssMessage = string.Empty;
        if (Type == MessageType.Error)
        {
            CssMessage += "error";

        }
        if (Type == MessageType.Success)
        {
            CssMessage += "success";
        }
        if (Type == MessageType.Warning)
        {
            CssMessage += "warning";

        }

        base.OnPreRender(e);
    }




    #region IMessage Members

    public void ShowMessage(List<Message> messages,MessageType type)
    {
        Type = type;
        Repeater1.DataSource = messages;
        Repeater1.DataBind();
    }

    #endregion
}
